package Week3;

import java.util.*;
import java.io.*;

public class Day17 {
}

//牛客:BC45 小乐乐改数字
class Main11 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        char[] s = in.next().toCharArray();
        int n = s.length;
        for(int i = 0; i < n; i++){
            //Java在算术运算时会自动将char类型隐式提升为int类型
            //因此字符会转换为对应的Unicode编码的整数值，在进行计算
            if(s[i] % 2 == 0) s[i] = '0';
            else s[i] = '1';
        }
        int i = 0;
        while(i < n-1 && s[i] == '0') i++;
        while(i < n) System.out.print(s[i++]);
    }
}

//牛客:十字爆破
class Main12 {
    public static Read2 in = new Read2();
    public static PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    public static void main(String[] args) throws IOException{
        int n = in.nextInt() , m = in.nextInt();
        long[][] arr = new long[n][m];
        long[] row = new long[n];
        long[] col = new long[m];
        //计算一行所有数的总和 和 一列所有数的总和
        for(int i = 0; i < n; i++){
            for(int j = 0 ; j < m; j++){
                arr[i][j] = in.nextInt();
                row[i] += arr[i][j];
                col[j] += arr[i][j];
            }
        }
        //将每个位置对应的一整行和一整列加在一起 在减去两处叠加在一起重复的此位置，就是爆破的分数
        for(int i = 0; i < n; i++){
            for(int j = 0; j < m; j++){
                out.print(row[i] + col[j] - arr[i][j] + " ");
            }
            out.println("");
        }
        out.close();
    }
}

class Read2 {
    StringTokenizer st = new StringTokenizer("");
    BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
    String next() throws IOException {
        while (!st.hasMoreTokens()) {
            st = new StringTokenizer(bf.readLine());
        }
        return st.nextToken();
    }
    String nextLine() throws IOException {
        return bf.readLine();
    }

    int nextInt() throws IOException {
        return Integer.parseInt(next());
    }

    long nextLong() throws IOException {
        return Long.parseLong(next());
    }

    double nextDouble() throws IOException {
        return Double.parseDouble(next());
    }
}

//牛客:比那名居的桃子
//解法一:滑动窗口
class Main13 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt() , k = in.nextInt();
        long[] s = new long[n+1];
        long[] h = new long[n+1];
        long sSum = 0 , hSum = 0 , begin = 0;
        long sMax = 0 , hMin = 0;

        for(int i = 1; i <= n; i++){
            s[i] = in.nextLong();
        }
        for(int i = 1; i <= n; i++){
            h[i] = in.nextLong();
        }

        int left = 1 , right = 1;
        while(right <= n){
            //入窗口
            sSum += s[right];
            hSum += h[right];
            //出窗口
            while(right - left + 1 > k){
                sSum -= s[left];
                hSum -= h[left];
                left++;
            }
            //更新结果
            if(right - left + 1 == k){
                if(sSum > sMax){
                    begin = left;
                    sMax = sSum;
                    hMin = hSum;
                }else if(sSum == sMax && hSum < hMin){
                    begin = left;
                    hMin = hSum;
                }
            }
            right++;
        }
        System.out.println(begin);
    }
}

//解法二:前缀和
class Main14 {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt() , k = in.nextInt();
        long[] a = new long[n+1];
        long[] b = new long[n+1];
        for(int i = 1; i <= n; i++){
            a[i] = in.nextLong();
        }
        for(int i = 1; i <= n; i++){
            b[i] = in.nextLong();
        }

        long[] sSum = new long[n+1];
        long[] hSum = new long[n+1];

        //计算每个位置的前缀和
        for(int i = 1; i <= n; i++){
            sSum[i] += sSum[i-1] + a[i];
            hSum[i] += hSum[i-1] + b[i];
        }

        long[] sum1 = new long[n+1];
        long[] sum2 = new long[n+1];
        long begin = 0;
        long smax = Integer.MIN_VALUE , smin = Integer.MAX_VALUE;
        //遍历前缀和数组
        for(int i = 1; i <= n; i++){
            //保证右区间是有效的，如果不进行保证，我们右边有的值是无法进行计算的
            int r = Math.min(i + k - 1 , n);
            //确定从i开始到i+k 或 n 的区间和
            sum1[i] =  sSum[r] - sSum[i - 1];
            sum2[i] =  hSum[r] - hSum[i - 1];
            //如果区间快乐值大于目前的最大快乐值就更新新的最大快乐值和最小羞耻值(是目前最大快乐值对应的最小值，不是整个前缀和数组的最小)就更新
            if(sum1[i] > smax){
                smax = sum1[i];
                smin = sum2[i];
                //记录位置
                begin = i;
            }else if(sum1[i] == smax && sum2[i] < smin){//如果快乐值与最大快乐值相同，并且羞耻值小于最小羞耻值就更新
                smin = sum2[i];
                //记录位置
                begin = i;
            }//其他情况保持不变
        }
        //返回是第几天
        System.out.println(begin);
    }
}